import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_shop/provide/goods_detail_provide.dart';
import 'package:provide/provide.dart';

class GoodsTabbar extends StatelessWidget {
  const GoodsTabbar({ Key key }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Provide<GoodsDetailProvider>(
      builder: (context, child, goodsDetailProvider) {
        return Row(
          children: <Widget>[
            _containerDiy(context, 'left', Text('详情', style: TextStyle(color: goodsDetailProvider.isLeft ? Colors.pink : Colors.black87, fontSize: 14.0, fontWeight: FontWeight.w700),)),
            _containerDiy(context, 'right', Text('评论', style: TextStyle(color: goodsDetailProvider.isRight ? Colors.pink : Colors.black87, fontSize: 14.0, fontWeight: FontWeight.w700),)),
          ],
        );
      }
    );
  }

  Widget _containerDiy (context, pos, Widget child) {
    return GestureDetector(
      child: Container(
        width: ScreenUtil().setWidth(375.0),
        height: ScreenUtil().setHeight(100.0),
        decoration: BoxDecoration(
          color: Colors.transparent
        ),
        child: Center(
          child: child,
        ),
      ),
      onTap: () {
        print('pos $pos');
        Provide.value<GoodsDetailProvider>(context).changeLeftAndRight(pos);
      },
    );
  }
}